Skip to content

KAFKA-20297: move Scheduler from client common to trogdor#21753

Merged
chia7712 merged 4 commits intoapache:trunkfrom
cychiu8:KAFKA-20297-move-scheduler-to-trogdor
Mar 18, 2026
Merged

KAFKA-20297: move Scheduler from client common to trogdor#21753
chia7712 merged 4 commits intoapache:trunkfrom
cychiu8:KAFKA-20297-move-scheduler-to-trogdor

Conversation

@cychiu8
Copy link
Contributor

@cychiu8 cychiu8 commented Mar 14, 2026

Summary This PR refactors the Scheduler utility and its
implementations by moving them from the clients module to the
trogdor module. It also ensures that client-side tests that previously
relied on MockScheduler remain functional by implementing a local
version where needed.

Key Changes - Package Relocation: Moved Scheduler,
SystemScheduler, and MockScheduler from
org.apache.kafka.common.utils to
org.apache.kafka.trogdor.common. - Trogdor Updates: Updated all
references in the trogdor module (including Agent, Coordinator,
TaskManager, and WorkerManager) to point to the new location
of the Scheduler interface and its implementations. - Client Test
Stability: Added a private MockScheduler inner class to
ExpiringCredentialRefreshingLoginTest.java. This replaces the
dependency on the global MockScheduler that was moved to Trogdor,
keeping the clients module tests decoupled from trogdor. - Cleaned
Up Imports: Removed unused imports and updated package declarations
across 13 files to reflect the architectural shift.

Reviewers: Chia-Ping Tsai chia7712@gmail.com

@github-actions github-actions bot added triage PRs from the community tools clients small Small PRs labels Mar 14, 2026
@cychiu8 cychiu8 force-pushed the KAFKA-20297-move-scheduler-to-trogdor branch from 38cf2b2 to b17f21a Compare March 17, 2026 02:28
}

@Override
public synchronized void onTimeUpdated() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

        @Override
        public synchronized void onTimeUpdated() {
            long timeMs = time.milliseconds();
            var iterator = waiters.entrySet().iterator();
            while (iterator.hasNext()) {
                var entry = iterator.next();
                if (entry.getKey() > timeMs) break;
                entry.getValue().forEach(future -> future.complete(timeMs));
                iterator.remove();
            }
        }

/**
* Futures which are waiting for a specified wall-clock time to arrive.
*/
private final TreeMap<Long, List<KafkaFutureImpl<Long>>> waiters = new TreeMap<>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Map<Long, List<KafkaFutureImpl<Long>>>

}
}

/*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you remove unused comment?

* limitations under the License.
*/
package org.apache.kafka.common.utils;
package org.apache.kafka.trogdor.common;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we inline SystemScheduler?

public interface Scheduler {
    Scheduler SYSTEM = new Scheduler() {

        @Override
        public Time time() {
            return Time.SYSTEM;
        }

        @Override
        public <T> Future<T> schedule(ScheduledExecutorService executor, Callable<T> callable, long delayMs) {
            return executor.schedule(callable, delayMs, TimeUnit.MILLISECONDS);
        }
    };

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the suggestion!! done in 4391eac

import org.apache.kafka.common.utils.Scheduler;
import org.apache.kafka.common.utils.Utils;

import com.fasterxml.jackson.databind.JsonNode;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TROGDOR_COORDINATOR_HEARTBEAT_MS and TROGDOR_COORDINATOR_HEARTBEAT_MS_DEFAULT are unused. Could you remove them?

@github-actions github-actions bot removed small Small PRs triage PRs from the community labels Mar 18, 2026
@chia7712 chia7712 merged commit 363e4ae into apache:trunk Mar 18, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants